home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Tutorial
/
Stepstone_Tutorial
/
Apple.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
905b
|
42 lines
/*Objective_C Implementation of the Apple Class: Apple.m*/
#import "Apple.h"
@implementation Apple
//Create a new Apple using the superclass 'new' method
+create{
id newInstance; // local variable declaration
newInstance=[self new]; // create new instance
[newInstance flavor:"Delicious" diameter:3 color:"green"]; // initialize
return newInstance; // return the new instance
}
//Set the flavor of the instance variable of Apple objects
-flavor:(char*)aFlavor{
flavor=aFlavor;
return self;
}
//Return the value of the flavor instance variable
-(char*)flavor{
return flavor;
}
// Set all the instance variables in the Apple objects
-flavor:(char*)aFlavor diameter: (int) aSize color:(char*)aColor {
[self flavor:aFlavor];
[self diameter:aSize];
[self color:aColor];
return self;
}
//Tell an Apple to increase its diameter
-grow{
diameter = diameter+2;
return self;
}
@end